﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    class HocKyDAO
    {
        public static List<HocKyDTO> GetList()
        {
            SqlConnection ketNoi = AbstractDAO.Connection();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = ketNoi;
            cmd.CommandText = @"SELECT * FROM HOCKY";
            
            // Thực thi câu lệnh 
            List<HocKyDTO> ds = new List<HocKyDTO>();
            SqlDataReader boDoc = cmd.ExecuteReader();
            while (boDoc.Read())
            {
                HocKyDTO hk = new HocKyDTO();
                hk.id = boDoc.GetInt32(0);
                hk.value = boDoc.GetString(1);
                ds.Add(hk);
            }
            boDoc.Close();

            return ds;
        }
    }
}
